<?php
function __autoload($className){
    //Directories added here must be 
	//relative to the script going to use this file. 
	//New entries can be added to this list
    $directories = array(
      'lib/',
      'parser/'
    );

    //Add your file naming formats here
    $fileNameFormats = array(
      '%s.php',
      '%s.class.php',
      'class.%s.php',
      '%s.inc.php'
    );

    // this is to take care of the PEAR style of naming classes
    $path = str_ireplace('_', '/', $className);
   if(@include_once $path.'.php'){
        return;
    }
    
    foreach($directories as $directory){
			//$path = $directory.sprintf($fileNameFormat, $className);
			$fullpath = $directory.$path.'.php';
            if(file_exists($fullpath)){
                include_once $fullpath;
                return;
            }
    }
}

?>